Clover coverage report - Enterprise Web Services - 1.0
Coverage timestamp: Mon May 30 2005 17:10:32 CEST
file stats: LOC: 96   Methods: 2
NCLOC: 67   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
EWSProvider.java 12.5% 20.7% 100% 23.1%
coverage coverage
 1   
 /*
 2   
  * Copyright 2001-2004 The Apache Software Foundation.
 3   
  * 
 4   
  * Licensed under the Apache License, Version 2.0 (the "License");
 5   
  * you may not use this file except in compliance with the License.
 6   
  * You may obtain a copy of the License at
 7   
  * 
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  * 
 10   
  * Unless required by applicable law or agreed to in writing, software
 11   
  * distributed under the License is distributed on an "AS IS" BASIS,
 12   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  * See the License for the specific language governing permissions and
 14   
  * limitations under the License.
 15   
  */
 16   
 
 17   
 package org.apache.geronimo.ews.ws4j2ee.wsutils;
 18   
 
 19   
 import org.apache.axis.AxisFault;
 20   
 import org.apache.axis.MessageContext;
 21   
 import org.apache.axis.handlers.soap.SOAPService;
 22   
 import org.apache.axis.providers.java.RPCProvider;
 23   
 import org.apache.axis.utils.ClassUtils;
 24   
 
 25   
 import java.io.InputStream;
 26   
 import java.lang.reflect.Method;
 27   
 
 28   
 /**
 29   
  * register the MessageContext in the jax-rpc runtime of the JSR109
 30   
  *
 31   
  * @author Srinath Perera(hemapani@opensource.lk)
 32   
  */
 33   
 public class EWSProvider extends RPCProvider {
 34   
     public static final String OPTION_EJB_NAME = "beanName";
 35   
     public static final String OPTION_JNDI_LOOKUP_NAME = "beanJndiName";
 36   
     public static final String OPTION_HOMEINTERFACE_NAME = "homeInterfaceName";
 37   
     public static final String OPTION_REMOTEINTERFACE_NAME = "remoteInterfaceName";
 38   
     public static final String OPTION_LOCALHOMEINTERFACE_NAME = "localHomeInterfaceName";
 39   
     public static final String OPTION_LOCALINTERFACE_NAME = "localInterfaceName";
 40   
     public static final String OPTION_USE_EJB = "j2eeStyle";
 41   
 
 42   
     private String ejblookupName;
 43   
     private String localhome;
 44   
     private String home;
 45   
     private String remote;
 46   
     private String local;
 47   
 
 48   
     private boolean ejbbased = false;
 49   
 
 50  2
     protected Object makeNewServiceObject(MessageContext msgContext,
 51   
                                           String clsName)
 52   
             throws Exception {
 53  2
         SOAPService service = msgContext.getService();
 54  2
         String j2eeStyle = (String) service.getOption(OPTION_USE_EJB);
 55  2
         if("ejb".equals(j2eeStyle) ){
 56  0
             java.util.Properties env = new java.util.Properties();
 57  0
             InputStream jndiIn = ClassUtils.getResourceAsStream(getClass(), "jndi.properties");
 58  0
             if (jndiIn != null) {
 59  0
                 env.load(jndiIn);
 60   
             } else {
 61  0
                 throw new AxisFault("Do not find the JNDI properties file in the class path");
 62   
             }
 63  0
             javax.naming.Context initial = new javax.naming.InitialContext(env);
 64  0
             ejblookupName = (String) service.getOption(OPTION_JNDI_LOOKUP_NAME);
 65  0
             remote = (String) service.getOption(OPTION_REMOTEINTERFACE_NAME);
 66  0
             home = (String) service.getOption(OPTION_HOMEINTERFACE_NAME);
 67  0
             local = (String) service.getOption(OPTION_LOCALINTERFACE_NAME);
 68  0
             localhome = (String) service.getOption(OPTION_LOCALHOMEINTERFACE_NAME);
 69  0
             if (remote != null && home != null && ejblookupName != null) {
 70  0
                 Object objref = initial.lookup(ejblookupName);
 71  0
                 Class homeClass = ClassUtils.forName(home);
 72  0
                 Object homeObj = javax.rmi.PortableRemoteObject.narrow(objref, homeClass);
 73  0
                 Method method = homeClass.getMethod("create", new Class[]{});
 74  0
                 return method.invoke(homeObj, new Object[]{});
 75  0
             } else if (local != null && localhome != null && ejblookupName != null) {
 76  0
                 Object homeObj = initial.lookup("java:comp/" + ejblookupName);
 77  0
                 Class homeClass = ClassUtils.forName(localhome);
 78  0
                 Method method = homeClass.getMethod("create", new Class[]{});
 79  0
                 return method.invoke(homeObj, new Object[]{});
 80   
             }
 81  0
             throw new AxisFault("Wrong configuration remote="+ remote + "home =" + home + "ejblookupName" + ejblookupName );
 82   
         } else {
 83  2
             return super.makeNewServiceObject(msgContext, clsName);
 84   
         }
 85   
     }
 86   
 
 87  2
     protected Object invokeMethod(MessageContext msgContext,
 88   
                                   Method method,
 89   
                                   Object obj,
 90   
                                   Object[] argValues)
 91   
             throws Exception {
 92  2
         Method invokeMethod = obj.getClass().getMethod(method.getName(), method.getParameterTypes());
 93  2
         return invokeMethod.invoke(obj, argValues);
 94   
     }
 95   
 }
 96